//
//  CommonEvaluateBottomView.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/12.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "CommonEvaluateBottomView.h"

@implementation CommonEvaluateBottomView

- (void)awakeFromNib {
    [super awakeFromNib];
        

    UIImageView *imgv = [[UIImageView alloc] initWithFrame:CGRectMake(12, 12, 13, 16)];
    [imgv setImage:[UIImage imageNamed:@"input_edit"]];
    
    UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    leftView.backgroundColor = [UIColor clearColor];
    [leftView addSubview:imgv];
    
    self.contentTF.leftView =leftView;
    self.contentTF.leftViewMode = UITextFieldViewModeAlways;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.contentTF pp_clipCorners:UIRectCornerAllCorners radius:self.contentTF.frame.size.width/2];
    });
    
}

- (void)fillWithModel:(CommonPostModel *)model {
    
    [self.postEvaBtn setTitle:[NSString stringWithFormat:@" %ld",model.replyCount] forState:UIControlStateNormal];
    [self.postThumbBtn setTitle:[NSString stringWithFormat:@" %ld",model.likes] forState:UIControlStateNormal];
        
    if (model.isZan.length > 0) {
        [self.postThumbBtn setImage:[UIImage imageNamed:@"tanhun_zan_sel"] forState:UIControlStateNormal];
        [self.postThumbBtn setTitleColor:UIColorHex(0xFF4242) forState:UIControlStateNormal];
    } else {
        [self.postThumbBtn setImage:[UIImage imageNamed:@"tanhun_zan"] forState:UIControlStateNormal];
        [self.postThumbBtn setTitleColor:UIColorHex(0x333333) forState:UIControlStateNormal];
    }
    
}

- (IBAction)shareAction:(id)sender {
    if (self.CommonEvaluateBottomViewBlock) {
        self.CommonEvaluateBottomViewBlock(CommunityActionType_Share);
    }
}

- (IBAction)evaAction:(id)sender {
    if (self.CommonEvaluateBottomViewBlock) {
        self.CommonEvaluateBottomViewBlock(CommunityActionType_Eva);
    }
}

- (IBAction)thumbAction:(id)sender {
    if (self.CommonEvaluateBottomViewBlock) {
        self.CommonEvaluateBottomViewBlock(CommunityActionType_Thumb);
    }
}


@end
